﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tireguit.Nmon.UI.Elements.Logical;

namespace Tireguit.Nmon.UI.Elements.Controls
{
    public partial class InformationTree : UserControl
    {
        protected TreeElement _treeelement = null;
        public TreeElement TreeElement 
        {
            get { return _treeelement; }
            protected set { _treeelement = value; }
        }
        public IDbConnection Connection { get; protected set; }
        public TreeViewEventHandler Treeviewhandler = null;
        protected void handleselecttree(object o,TreeViewEventArgs e)
        {
            if (Treeviewhandler!=null)
            {
                Treeviewhandler(o, e);
            }

        }
        public InformationTree(IDbConnection connection)
        {
            Connection = connection;
            InitializeComponent();
            InitNodes();
        }
        protected void InitNodes()
        {
            _treeelement = new TreeElement(Connection);
            treeView1.Nodes.Add(_treeelement.RootElement);
            treeView1.ExpandAll();
            treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(handleselecttree);
        }
    }
}
